<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>后台管理</title>
<link rel="stylesheet" href="/static/res/css/admin.css">
<link rel="stylesheet" href="/static/res/layui/css/layui.css">
<script src="/static/res/layui/jquery-3.3.1.js" charset="utf-8"></script>
<script src="/static/res/layui/layui.all.js" charset="utf-8"></script>


</head>
<body id="login">
<div class="login">
<h2>后台管理</h2>
<form class="layui-form" method="post">
<div class="layui-form-item">
<input type="text" name="username" placeholder="请输入账号" required lay-verify="required" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-item">
<input type="password" name="password" placeholder="请输入密码" required lay-verify="required" autocomplete="off" class="layui-input">
</div>
 
<div class="layui-form-item">
<input style="width:100px;float:left;margin-right: 10px;" type="text" name="captcha" placeholder="验证码" required lay-verify="required" autocomplete="off" class="layui-input">
<img id="captcha1" src="{:captcha_src()}" onclick="this.src='{:captcha_src()}?'+Math.random();" width="150" style="float:left; cursor:pointer;" alt="captcha" />
</div>

<div class="layui-form-item">
<button style="padding: 0 102px;" class="layui-btn" lay-submit="" lay-filter="login_index" id="admin_login">立即登录</button>
</div>
</form>


<script>
$(function(){
	$('#admin_login').click(function(){
		$.ajax({
			url:"{:url('admin/index/login')}",
			type:"post",
			data:$('form').serialize(),
			dataType:"json",
			success:function(data){
				if(data.code ==1){
					layer.msg(data.msg, {
						icon:6,
						time:2000
					},function(){
						location.href = data.url;
					});
				} else {
					layer.open({
						title:'登陆失败',
						content:data.msg,
						icon:5,
						anim:6
					});
				}
			}
		});
		return false;
	});

});

</script>

</div>
</body>
</html>